package main;

import java.util.HashMap;
import java.util.HashSet;

public class ReservedSymbols {
	public static final String S_WHILE = "while";
	public static final String S_DO = "do";
	public static final String S_IF = "if";
	public static final String S_ELSE = "else";
	public static final String S_INPUT = "input";
	public static final String S_OUTPUT = "output";
	public static final String S_EQUALS_IDENTIFIER = ":=";
	public static final String S_EOL_IDENTIFIER = ";";
	public static final String S_CONDITIONAL_START_IDENTIFIER = "(";
	public static final String S_CONDITIONAL_END_IDENTIFIER = ")";
	public static final String S_BLOCK_START_IDENTIFIER = "{";
	public static final String S_BLOCK_END_IDENTIFIER = "}";
	public static final String S_GTSYMBOL = ">";
	public static final String S_LTSYMBOL = "<";
	public static final String S_GTESYMBOL = ">=";
	public static final String S_LTESYMBOL = "<=";
	public static final String S_EQUIVSYMBOL = "==";
	public static final String S_PLUS = "+";
	public static final String S_MINUS = "-";
	public static final String S_MULTIPLY = "*";
	public static final String S_DIVIDE = "/";
	public static final String S_NOTEQL = "!=";
	public static final String S_NEGATIVE = "-";
	
	public static final HashSet<String> opSymbols = new HashSet<String>();
	
//	public static HashMap<String, Integer> symbols = new HashMap<String, Integer>();


	/**
	 * If token contains a reserved symbol.
	 */
	public static Boolean containsReservedSymbol(String word) {
		if (word.contains(S_WHILE) ||
			word.contains(S_DO) ||
			word.contains(S_IF) ||
			word.contains(S_ELSE) ||
			word.contains(S_INPUT) ||
			word.contains(S_OUTPUT) ||
			word.contains(S_EQUALS_IDENTIFIER) ||
			word.contains(S_EOL_IDENTIFIER) ||
			word.contains(S_CONDITIONAL_START_IDENTIFIER) ||
			word.contains(S_CONDITIONAL_END_IDENTIFIER) ||
			word.contains(S_BLOCK_START_IDENTIFIER) ||
			word.contains(S_BLOCK_END_IDENTIFIER) ||
			word.contains(S_GTSYMBOL) ||
			word.contains(S_GTESYMBOL) ||
			word.contains(S_LTSYMBOL) ||
			word.contains(S_LTESYMBOL) ||
			word.contains(S_EQUIVSYMBOL) ||
			word.contains(S_MULTIPLY) ||
			word.contains(S_DIVIDE) ||
			word.contains(S_PLUS) ||
			word.contains(S_MINUS) ||
			word.contains(S_NOTEQL))
		{
			return true;
		}
		return false;
	}

	/**
	 * Contains identifier.
	 * @param str token to check
	 * @return true if contained false otherwise
	 */
	public static Boolean containsIdentifier(String str) {
		if (str.contains(S_CONDITIONAL_START_IDENTIFIER) || 
				str.contains(S_CONDITIONAL_END_IDENTIFIER) || 
				str.contains(S_BLOCK_START_IDENTIFIER) ||	
				str.contains(S_BLOCK_END_IDENTIFIER))
		{
			return true;
		}
		return false;
	}

	/**
	 * Contains while, if, else.
	 * @param str token to check
	 * @return true if contained false otherwise
	 */
	public static Boolean containsConditional(String str) {
		if (str.contains(S_WHILE) || 
				str.contains(S_IF) || 
				str.contains(S_ELSE) || 
				str.contains(S_DO)) {
			return true;
		}
		return false;
	}

	/**
	 * Any operation
	 * @param str token to check
	 * @return true if contains false otherwise
	 */
	public static Boolean containsOperation (String str) {
		if (str.contains(S_GTSYMBOL) || 
				str.contains(S_GTESYMBOL) ||
				str.contains(S_LTSYMBOL) ||
				str.contains(S_LTESYMBOL) ||
				str.contains(S_EOL_IDENTIFIER) ||
				str.contains(S_PLUS) || 
				str.contains(S_MINUS) || 
				str.contains(S_MULTIPLY) || 
				str.contains(S_DIVIDE) ||
				str.contains(S_EQUALS_IDENTIFIER) ||
				str.contains(S_EQUIVSYMBOL) ||
				str.contains(S_NOTEQL) ||
				str.contains(S_NEGATIVE))
		{
			return true;
		}
		return false;
	}

	/**
	 * Input or output contained in token
	 * @param str token
	 * @return true if input or output false otherwise
	 */
	public static Boolean containsIO(String str) {
		if (str.contains(S_INPUT) ||
				str.contains(S_OUTPUT))
		{
			return true;
		}
		return false;
	}
}